package com.wanghua.mall.user.webcontroller;

import com.wanghua.common.utils.R;
import com.wanghua.mall.user.openfeign.UserClient;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.net.http.HttpRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wanghua
 * @create 2021-09-11 8:50
 */
@Controller
public class UserWebController {

    @Resource
    private UserClient userClient;

    @GetMapping("/userOrder.html")
    public String userOrderPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                Model model, HttpRequest request) {
        //查出当前用户的所有订单列表数据
        Map<String, Object> params = new HashMap<>();
        params.put("page", pageNum.toString());
        R r = userClient.listWithItem(params);
        model.addAttribute("orders", r);

        return "orderList";
    }
}
